<?php
/**
 * Created by PhpStorm.
 * User: Jan-Home
 * Date: 2018/4/5 0005
 * Time: 18:17
 */

namespace Gitee\GiteeAPI;


class OrgAPI extends CoreAPI
{
	
	public static function filterOrgName($org, $type = 0)
	{
		if (is_object($org) && $org instanceof OrgModelImpl) {
			if ($type === 0)
				return $org->getOrgLoginName();
			else
				return $org->getEnterpriseLoginName();
		}
		if (is_string($org)) {
			return $org;
		}
		return '';
	}
	
	public function info($org)
	{
		$org = static::filterOrgName($org, 0);
		return $this->request("orgs/{$org}");
	}
	
	public function members($org, $role = null, int $page = 1)
	{
		$org = static::filterOrgName($org, 0);
		$this->setUsePage(true)->setQueryOption('role', self::QUERY_ROLE);
		return $this->request("orgs/{$org}/members", [
			'page' => 1,
			'role' => $role,
		]);
	}
	

}